package logic

import (
	"context"
	"shop_srv/model/redis"

	"shop_srv/internal/svc"
	"shop_srv/shop"

	"github.com/zeromicro/go-zero/core/logx"
)

type GoodsCountLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGoodsCountLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GoodsCountLogic {
	return &GoodsCountLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *GoodsCountLogic) GoodsCount(in *shop.GoodsCountRequest) (*shop.GoodsCountResponse, error) {
	// todo: add your logic here and delete this line
	count, price, _ := redis.Sum(in.UserId)
	return &shop.GoodsCountResponse{Num: int64(count), Price: float32(price)}, nil
}
